package com.njym.java.oss.controller; /**
 * @Title: LiveController
 * @ProjectName family-benefit
 * @Description: TODO
 * @author 71705
 * @date 2019/12/1814:51
 */

import com.njym.java.config.AliyunLiveConfig;
import com.njym.java.util.AliyunLiveUtil;
import com.njym.java.util.LiveTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.UUID;

/**
 * @program: family-benefit
 * @description:
 * @author: lijie
 * @create: 2019-12-18 14:51
 **/
@RestController
@RequestMapping("/live")
@Slf4j
public class LiveController {

    @Autowired
    private AliyunLiveConfig aliyunLiveConfig;

    @GetMapping("addLive")
    @ResponseBody
    public Object addLive(Integer courseId) {
/**
         * 注意，推流要在播流域名里面生成
         */

        System.out.println(aliyunLiveConfig.toString());

        String pushUrl = AliyunLiveUtil.createPushUrl(courseId, LiveTypeEnum.course, aliyunLiveConfig);
        log.debug("推流域名=" + pushUrl);

        Map<String, String> pullUrl = AliyunLiveUtil.createPullUrl(courseId, LiveTypeEnum.course, aliyunLiveConfig);
//        log.debug("拉流域名=" + pullUrl.toString());

        pullUrl.put("pushUrl",pushUrl);
        return pullUrl;
    }

    public static void main(String[] args) {
        String s = UUID.randomUUID().toString().replaceAll("-", "");
        System.out.println(s);
    }


}
